<!DOCTYPE html>
<html lang="en">
<head>
    <link rel="stylesheet" href="css/login.css">
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0,user-scalable=no,maximum-scale=1.0">
    <title>Document</title>
</head>
<body>
<div class="lh">
    <div class="lh1" onclick="tzs()">
    </div>
     <span >京东登录注册</span> 
</div>
<form method="post"action=""name="form1"autocomplete="off">
    <input  type="text" name="username"id="username"class="intext1"value=""placeholder="用户名/邮箱/手机号"/>
    <hr>
    <input type="password" name="password"id="password"class="intext2"value=""placeholder="请输入密码"/>
    <hr>
    <input type="button" onclick="check()"value="登录"class="btn"/>
    <input type="button" onclick="check()" value="一键登录" class="btn1">
    
</form>
</body>
<script>
    function tzs(){
        if(window.history.back(-1)==null)
        {
        window.location.href="index.html";
        }
        else{
        window.history.back(-1);
        }
    }
</script>
<script>
    var db= openDatabase('testDB','1.0','Test DB',3*1024*1024);
    var u=document.getElementById('username');
    var p=document.getElementById('password');
    var msg;
    db.transaction(function(context){
        context.executeSql('CREATE TABLE IF NOT EXISTS users(id unique,username,password)');
        context.executeSql('INSERT INTO users(id,username,password)VALUES(0,15870861752,"753159tu")');
        context.executeSql('INSERT INTO users(id,username,password)VALUES(1,123,"b")');
    });
    db.transaction(function(context){
    context.executeSql('SELECT *FROM users',[],function(context,results){
        var len=results.rows.length,i;
        console.log('Got ',len,'rows.');
        for(i=0;i<len;i++){
            console.log('id:'+results.rows.item(i).id);
            console.log('username:'+results.rows.item(i).username);
            console.log('password:'+results.rows.item(i).password);
        }
    });
    });
    function check(){
        var a=false;
        db.transaction(function(context){
        context.executeSql('SELECT *FROM users',[],function(context,results){
        var len=results.rows.length,i;
        console.log('Got ',len,'rows.');
        for(i=0;i<len;i++){
          if(u.value==results.rows.item(i).username &&p.value==results.rows.item(i).password){
          window.location.href="index.html";
          a=true;
          }
        }
       if(a==false){
        alert("账号用户名或者密码错误");
       }
    });
    });
    }
</script>
</html>